<?php


namespace App\Http\Controllers\applets\model;


use Illuminate\Support\Facades\DB;

class AdminAppModel
{
    public static function queryFirst($where,$field){
        return DB::table('t_admin_app')->where($where)->first($field);
    }

    public static function queryAll($where=[],$param=[]){
        $field = ['a.id','app_name','app_img','s.name','app_developer','app_size','app_downloads as app_installs','app_package','app_version_name','a.app_remarks'];
        if(isset($param['field'])){
            return DB::table('t_admin_app as a')
                ->leftJoin('t_subject as s','a.app_subject_id','=','s.id')
                ->where($where)
                ->where("$param[field]",'like','%'.$param["$param[field]"].'%')
                ->get($field);
        }
        return DB::table('t_admin_app as a')
            ->leftJoin('t_subject as s','a.app_subject_id','=','s.id')
            ->where($where)
            ->get($field);
    }

    public static function edit($where,$param){
        return DB::table('t_admin_app')->where($where)->update($param);
    }
}